/*--------------------------------------------------------------------------------------*\
**
** t_kingdom_overview_window.h
**
** Heroes IV
** Copyright 2000, The 3DO Company
**
\*--------------------------------------------------------------------------------------*/

#ifndef KINGDOM_OVERVIEW_WINDOW_H_INCLUDED
#define KINGDOM_OVERVIEW_WINDOW_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#pragma warning( disable: 4786 )

#include "bitmap_layer_cache_window.h"
#include "bound_handler.h"
#include "button.h"
#include "game_window.h"
#include "mini_map_window.h"
#include "skill_icon_ptr.h"

class t_adventure_frame;
class t_adventure_map;
class t_adventure_map_window;
class t_army;
class t_creature_array;
class t_hero;
class t_luck_icon_window;
class t_morale_icon_window;
class t_player;
class t_scrollbar;
class t_toggle_button;
class t_town;

class t_kingdom_overview_window : public t_window
{
    enum {
        k_max_army_list_windows = 5,
        k_max_hero_list_windows = 5,
        k_max_town_list_windows = 3,
	    k_max_skill_icons_to_display = 5,
		k_skill_frame_rows = 5,
		k_skill_frame_columns = 4,
    };

public:
	t_kingdom_overview_window( t_window* parent, t_adventure_frame* map_ptr,
							   t_player * player_ptr );

protected:
    t_adventure_frame *         m_adventure_frame_ptr;
    t_adventure_map_window *    m_adventure_map_window_ptr;
    t_window_ptr				m_army_leader_highlight;
	t_window *                  m_army_list_window;
	t_bitmap_group_ptr		    m_army_list_bitmaps_ptr;
	int                         m_army_list_starting_index;
	std::vector<t_window*>      m_army_windows;
	t_bitmap_group_ptr		    m_background_bitmaps_ptr;
	t_skill_icon_ptr            m_frame_skills[k_skill_frame_rows][k_skill_frame_columns];
	std::vector<t_hero*>        m_heroes_list;
	std::vector<t_creature_array *> m_heroes_creatures_list;
	t_window *                  m_hero_background_ptr;
	t_bitmap_group_ptr		    m_hero_list_bitmaps_ptr;
    std::vector<t_level_map_point_2d>   m_hero_list_position;
	t_window *                  m_hero_list_window;
	int                         m_hero_selected;
	std::vector<t_window*>      m_hero_windows;
	t_luck_icon_window *        m_luck_icon_ptr;
	t_morale_icon_window *      m_morale_icon_ptr;
	t_player *			        m_player_ptr;
    std::vector<t_toggle_button*>   m_portrait_button_list;
	t_scrollbar *               m_scrollbar;
	t_window *                  m_town_list_window;
	t_bitmap_group_ptr		    m_town_list_bitmaps_ptr;
	std::vector<t_window*>      m_town_windows;
    t_text_window*				m_damage_text;
    t_text_window*				m_experience_text;
    t_window_ptr				m_experience_icon;
    t_text_window*				m_health_text;
    t_text_window*				m_luck_text;
    t_text_window*				m_movement_text;
    t_text_window*				m_morale_text;
    t_text_window*				m_spell_points_text;
    t_text_window*				m_speed_text;

    void    army_leader_clicked( t_button *button_ptr, t_army * army_ptr, int index );
    void    army_list_click( t_button *button_ptr );
    void    army_leader_double_clicked( t_button *button_ptr, t_army* army_ptr );
    void    army_list_scrollbar_move( t_scrollbar* scrollbar, int value );
    void    close_click( t_button *button_ptr );
    void    create_army_frame( t_army * army_ptr, int index );
    void    create_army_list_screen();
    void    create_army_leader_frame( t_window* window_ptr, t_army * army_ptr );
    void    create_hero_frame( t_hero * hero_ptr, t_level_map_point_2d hero_point, int index );
    void    create_hero_list_screen();
    void    create_skill_frames();
    void    create_town_frame( t_town * town_ptr );
    void    create_town_list_screen();
    void    display_hero_stats( t_hero const* hero_ptr, t_creature_array * creatures );
    void    hero_bio_clicked( t_button *button_ptr );
    void    hero_list_click( t_button *button_ptr );
    void    hero_list_scrollbar_move( t_scrollbar* scrollbar, int value );
    void    hero_portrait_clicked( t_button *button_ptr, int index );
    void    hero_portrait_double_clicked( t_button *button_ptr, int index );
    void    hero_spellbook_clicked( t_button *button_ptr );
    void    hide_army_list_screen();
    void    hide_hero_list_screen();
    void    hide_town_list_screen();
    void    show_army_list_screen( int index );
    void    show_hero_list_screen( int index );
    void    show_skill_frames( t_hero const* hero_ptr );
    void    show_town_list_screen( int index );
    void    town_image_clicked( t_button *button_ptr, t_town * town_ptr );
    void    town_image_double_clicked( t_button *button_ptr, t_town * town_ptr );
    void    town_list_click( t_button *button_ptr );
    void    town_list_scrollbar_move( t_scrollbar* scrollbar, int value );
};

/*----------------------------------------------------------------------------------*\
**
** Mini-map class for showing location and centering on location.
**
** Class derived from mini_map.
**
\*----------------------------------------------------------------------------------*/
class t_center_map_window : public t_window, public t_mini_map_renderer
{
public:
	t_center_map_window( t_adventure_map const& map, t_screen_rect const& rect,
	               t_adventure_map_window* map_window, t_window* parent );

	virtual void         paint( t_paint_surface& paint_surface );
protected:
	void         center_view( t_screen_point point );
	// Member functions
	virtual t_shared_ptr< t_abstract_bitmap16 > create_back_buffer( t_screen_point const & size );
	virtual void on_rect_dirtied( t_screen_rect const & dirted_rect );
	virtual void on_size_change( t_screen_rect const& rect ); // in client coordinates of parent
	virtual void on_view_level_changed( int level );
	virtual void on_view_resized( t_screen_point const & size );

	t_counted_ptr<t_adventure_map_window>	m_map_window;
	t_shared_ptr<t_memory_bitmap16> m_back_buffer;
	bool									m_dragging;
};

#endif //KINGDOM_OVERVIEW_WINDOW_H_INCLUDED
